<template>
	<view class="write-off-record">
		<nav-bar title="核销记录" />
		<view class="list">
			<view class="item" v-for="(item, index) in list" :key="index">
				<view class="left">
					<u-avatar :src="item.headavatar" size="72" class="avatar"></u-avatar>
					<view class="info">
						<text class="name">{{item.name}}</text>
						<text class="coupon">{{item.coupon_name}}</text>
					</view>
				</view>
				<view class="right">
					<view :class="{'status': true, 'success': item.status == 1, 'fail': item.status == 0}">
						{{item.status | formatStatus}}
					</view>
					<view class="time">{{item.time}}</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		writeOffReecordApi
	} from "@/api/store.js"
	export default {
		data() {
			return {
				list: []
			}
		},
		filters: {
			formatStatus(val) {
				let str = ''
				switch (val) {
					case 1:
						str = '核销成功'
						break
					case 0:
						str = '核销失败'
						break
				}
				return str
			}
		},
		onLoad() {
			this.getData()
		},
		methods: {
			async getData() {
				let {
					data
				} = await writeOffReecordApi()
				console.log(data);
				this.list = data
			}
		}
	}
</script>

<style scoped lang="scss">
	@import 'index.scss';
</style>
